﻿@model GridView<JCTimes.DomainModel.Views.V_Users>

@{
    int seq = (Model.PagedList.PageIndex - 1) * Model.PagedList.PageSize;
    var roleid = SessionHelper.CurrUser.RoleID;
}
<table class="table">
    <tr>
        <th style="width: 5%">
            序号
        </th>
        <th style="width: 10%">
            用户名
        </th>
        <th style="width: 10%">
            名称
        </th>
        @if (roleid == Constant.Admin)
        {
        <th style="width: 10%">
            所属代理商
        </th>
        }
        <th style="width: 10%">
            联系人名称
        </th>
        <th style="width: 10%">
            联系电话
        </th>
        <th style="width: 10%">
            手机
        </th>
            <th style="width: 15%">
                操作
            </th>     
    </tr>
    @foreach (var item in Model.PagedList)
    {
        <tr>
            <td style="text-align: center">
                @((++seq).ToString())
            </td>
            <td>
               <a href="/PDA/Index/?accountid=@item.ID"> @Html.DisplayFor(modelItem => item.UserName)</a>
            </td>
            <td class="showContext">
               <a href="/PDA/Index/?accountid=@item.ID"> @Html.DisplayFor(modelItem => item.Name)</a>
            </td>
            @if (roleid == Constant.Admin)
            {
            <td>
                <a href="/Account/Index/?agencyid=@item.ParentID">@Html.DisplayFor(modelItem => item.AgencyName)</a>
            </td>
            }
            <td class="showContext">
                @Html.DisplayFor(modelItem => item.ContactName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Tel)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Mobile)
            </td>
                <td>
                @Html.ImageLink(
                        "配置PDA权限",
            Url.Action("Config", new { id = item.ID }),
                     Url.Content("~/Images/icon_key.gif")
                    )
                    @Ajax.ImageLink(
                        "删除",
                        Url.Action("Delete", new { id = item.ID, pageIndex = Model.PagedList.PageIndex, searcher = Model.Searcher }),
                 Url.Content("~/Images/icon_del.gif"),
                        new AjaxOptions
                        {
                            Confirm = "确认删除吗?",
                            HttpMethod = "Post",
                            InsertionMode = InsertionMode.Replace,
                            UpdateTargetId = "gridview",
                        }
                    )
                    @if (roleid == Constant.Admin)
                    {
                    @Ajax.ImageLink(
                        "密码重置",
                        Url.Action("Reset", new { id = item.ID }),
                         Url.Content("~/Images/icon_history.gif"),
                         new AjaxOptions
                         {
                             Confirm = "确认重置吗?",
                             HttpMethod = "Post",
                             OnSuccess = "GetMsg"
                         }
                    )
                    }
                    @Html.ImageLink(
                        "编辑",
                     Url.Action("Edit", new { id = item.ID, pageIndex = Model.PagedList.PageIndex, searcher = Model.Searcher }),
                        Url.Content("~/Images/icon-edit.gif")
                    )
                    
                </td>
        </tr>
    }
</table>
<div>
    @if (Model.PagedList.PageCount > 1)
    {
        <div class="pager">
            <p>
                共有<span class="orange">@Model.PagedList.TotalCount</span> 条记录 共<span class="orange">@Model.PagedList.PageCount</span>页
            </p>
            @Ajax.PageLinks(Model.PagedList.PageCount, Model.PagedList.PageIndex, i => Url.Action("Grid", new { pageIndex = i, searcher = Model.Searcher }),
                     new AjaxOptions { UpdateTargetId = "gridview", HttpMethod = "Post" })
        </div>  
    }
</div>
